import request from '/@/utils/request'
// 查询流程模型列表
export function listFlowModel(query:object) {
  return request({
    url: '/api/v1/flow/flowModel/list',
    method: 'get',
    params: query
  })
}
// 查询流程模型详细
export function getFlowModel(id:number) {
  return request({
    url: '/api/v1/flow/flowModel/get',
    method: 'get',
    params: {
      id: id.toString()
    }
  })
}
// 新增流程模型
export function addFlowModel(data:object) {
  return request({
    url: '/api/v1/flow/flowModel/add',
    method: 'post',
    data: data
  })
}
// 修改流程模型
export function updateFlowModel(data:object) {
  return request({
    url: '/api/v1/flow/flowModel/edit',
    method: 'put',
    data: data
  })
}
// 删除流程模型
export function delFlowModel(ids:number[]) {
  return request({
    url: '/api/v1/flow/flowModel/delete',
    method: 'delete',
    data:{
      ids:ids
    }
  })
}
//相关连表查询数据
export function linkedDataSearch(){
  return request({
    url: '/api/v1/flow/flowModel/linkedData',
    method: 'get'
  })
}

export function saveModeNode(data:object){
  return request({
    url: '/api/v1/flow/flowModel/saveModelNode',
    method: 'post',
    data: data
  })
}

export function getNodeData(modelId:number){
  return request({
    url: '/api/v1/flow/flowModel/getModelNode',
    method: 'get',
    params:{modelId:modelId}
  })
}

//发起流程
export function wfStart(query:Object){
  return request({
    url: '/api/v1/flow/flowModel/wfStart',
    method: 'get',
    params:query
  })
}

//保存发起流程信息
export function saveStartWf(data:Object){
  return request({
    url: '/api/v1/flow/flowModel/wfSaveStart',
    method: 'post',
    data:data
  })
}


export function getCheckData(query:Object){
  return request({
    url: '/api/v1/flow/flowModel/checkData',
    method: 'get',
    params:query
  })
}

//保存审批信息
export function saveCheckWf(data:any){
  if (data.isProxy){
    return request({
      url: '/api/v1/flow/flowModel/proxy',
      method: 'post',
      data:data
    })
  }
  return request({
    url: '/api/v1/flow/flowModel/checkSave',
    method: 'post',
    data:data
  })
}

// 获取审批日志列表
export function checkLog(params:Object){
  return request({
    url: '/api/v1/flow/flowModel/log',
    method: 'get',
    params:params
  })
}

export function getRunStep(params:Object){
  return request({
    url: '/api/v1/flow/flowModel/runStep',
    method: 'get',
    params:params
  })
}
//获取流程监控信息
export function getMonitor(params:Object){
  return request({
    url: '/api/v1/flow/flowModel/monitor',
    method: 'get',
    params:params
  })
}
export function stopRun(ids:number[]){
  return request({
    url: '/api/v1/flow/flowModel/stopRun',
    method: 'put',
    data:{ids:ids}
  })
}
